﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Najak;

namespace Falon
{
	class Game : Najak.App
	{
		static public Game Create(IAppHost drawer, object contentMgr)
		{
			return new Game(drawer, contentMgr);
		}

		public Game(IAppHost drawer, object contentMgr)
			: base(drawer, contentMgr)
		{
		}

		public override void DrawHud()
		{
			Rectangle titleSafeArea = AppHost.GraphicsDevice.Viewport.TitleSafeArea;
			Vector2 hudLocation = new Vector2(titleSafeArea.X, titleSafeArea.Y);
			Vector2 center = new Vector2(titleSafeArea.X + titleSafeArea.Width / 2.0f, titleSafeArea.Y + titleSafeArea.Height / 2.0f);

			hudLocation.X += 5;
			hudLocation.Y += 5;

			hudLocation.Y = 500;

			if (GodPlayer.Instance.Selections.SelectedEntities.Count > 0)
			{
				Unit u = GodPlayer.Instance.Selections.SelectedEntities[0] as Unit;
				DrawShadowedString(_hudFont, "Unit: " + (u.Name), hudLocation, Color.Brown);
				hudLocation.Y += 20;
				DrawShadowedString(_hudFont, "Health: " + (u.Health), hudLocation, Color.Brown);
				if (u.Weapon != null)
				{
					hudLocation.Y += 20;
					DrawShadowedString(_hudFont, "Damage: " + (u.Weapon.Damage), hudLocation, Color.Brown);
				}
				if (u.Armor != null)
				{
					hudLocation.Y += 20;
					DrawShadowedString(_hudFont, "Armor: " + (u.Armor.Defense), hudLocation, Color.Brown);
				}
			}
			if (!String.IsNullOrEmpty(DebugMessage))
			{
				if (Time < _debugMessageExpiration)
				{
					hudLocation.Y += 40;
					DrawShadowedString(_hudFont, DebugMessage, hudLocation, Color.Yellow);
				}
				else
				{
					DebugMessage = null;
				}
			}
			hudLocation.X = 500;
			hudLocation.Y = 5;
			DrawShadowedString(_hudFont, "Screen: " + AppHost.ScreenLocation.X + ", " + AppHost.ScreenLocation.Y, hudLocation, Color.LightGreen);
			//DrawShadowedString(_hudFont, "Time: " + GameTime.TotalGameTime.ToString("m\\:ss"), hudLocation, Color.LightGreen);
			hudLocation.Y += 30;
			DrawShadowedString(_hudFont, "Mouse: " + InputHandler.Instance.MouseScreenLocation.X + ", " + InputHandler.Instance.MouseScreenLocation.Y, hudLocation, Color.Wheat);


			if (_timeTilStatusMessageExpires > 0)
			{
				DrawShadowedString(_hudFont, _statusMessage, new Vector2(100, 200), Color.Yellow);
				_timeTilStatusMessageExpires -= (float)GameTime.ElapsedGameTime.TotalMilliseconds;
			}
		}
	}
}
